function PopupOverlay(param) {

	var that = this;
	
	this.j_popup = null;
	this.j_popup_container = null;
	this.j_popup_close = null;
	this.j_popup_overlay = null;
	this.j_popup_trigger = null;
	
	function __construct(p) {
	try{
		for(pkey in p) {
			if(pkey[0] != "_") {
				that[pkey] = p[pkey];
			}
		}
		
		that.j_popup_overlay.click(closePopup);
		that.j_popup_close.click(closePopup);
		that.j_popup_trigger.live("click", showPopup);
		
	}catch(err) {
		alert(err);
	}
	}
	
	function showPopup(e) {
	try{
		e.preventDefault();

		if(!jq("body").hasClass("noscroll")) {
			jq("body").addClass("noscroll");
		}
		var popup_trigger = jq(this);
		var popup_data = popup_trigger.data("popup");
		
		var popup_width = popup_data.popup_width;
		var popup_margin_top = popup_data.popup_margin_top;
		var popup_src = popup_data.src;
		
		if(popup_width) {
			that.j_popup.css({ "width" : popup_width + "px" });
		}
		if(popup_margin_top) {
			that.j_popup.css({ "margin-top" : popup_margin_top + "px" });
		}
		that.j_popup_overlay.show();
		
		that.j_popup_container.load(popup_src, function(responseText, statusText, xhr) {
	        if(statusText == "success") {
	    		that.j_popup.show();
	        }
	        if(statusText == "error") {
				jq.notification({ "pos_top" : 200, "width" : 360, "message" : "Oops! An error occurred while processing your request." });
	        }
        });
		
     }catch(err) {
		alert(err);
	}
	}
	
	function closePopup(e) {
	try{
		var target = jq(e.target);
		if(target.is("[data-dom-id=popup-overlay]") || target.is("[data-dom-id=popup] a[href='#popup_close']")) {
			e.preventDefault();
			that.j_popup.hide();
			that.j_popup_overlay.hide();
			if(jq("body").hasClass("noscroll")) {
				jq("body").removeClass("noscroll");
			}
		}
	}catch(err) {
		alert(err);
	}
	}
    
	__construct(param);
	
}
